#ifndef __DAF_PARAM_H__
#define __DAF_PARAM_H__

#include "daf_model.h"

#include "gazella/async_message.h"

#include <vector>
#include <mutex>
#include <functional>
#include <string>
#include <map>

namespace Gazella {
namespace Daf {

struct ParamAsyncMessage: public IAsyncMessage {
    DeviceAgentModel::DeviceAgentProperty param;
};

typedef std::function<void(const DeviceAgentModel::DeviceAgentProperty&)> param_notify_func_t;

class DafParam {
private:
    DafParam();
    ~DafParam();

    void __async_message_notify(const std::shared_ptr<IAsyncMessage>& message);

public:
    static DafParam* get_instance();

    void init();

    bool set_param(const DeviceAgentModel::DeviceAgentProperty& param);
    bool get_param(const std::string& identifier, DeviceAgentModel::DeviceAgentProperty& param);

    //user's slot func will notify in main thread
    //so the notify func can't be blocked
    bool connect(const std::string& identifier, param_notify_func_t func);

private:
    std::vector<DeviceAgentMessage::DeviceAgentAbilityElement> m_param_abilities;

    std::mutex m_notifies_lock; 
    std::map<std::string, param_notify_func_t> m_param_notifies;

    GzAsyncMessage m_async;
};
}
}



#endif